#pragma warning disable 169, 414, 649
namespace Jsl.FxCop
{
    using Microsoft.FxCop.Sdk;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class TestMarkFieldReadOnly
    {
        private string privateInstance_NotSet_NotRead;

        [TestMethod]
        public void PrivateInstance_NotSet_NotRead()
        {
            new MarkFieldReadOnly()
                .RunRule(() => this.privateInstance_NotSet_NotRead)
                .HasProblem(
                    75,
                    FixCategories.NonBreaking,
                    MessageLevel.Warning,
                    "Remove the field 'privateInstance_NotSet_NotRead' since it is never set and therefore is always the default value.")
                .HasNoMoreProblems();
        }

        private string privateInstance_NotSet_Read;
        public void Read_field()
        {
            string x = this.privateInstance_NotSet_Read;
            string y = x;
        }

        [TestMethod]
        public void PrivateInstance_NotSet_Read()
        {
            new MarkFieldReadOnly()
                .RunRule(() => this.privateInstance_NotSet_Read)
                .HasProblem(
                    75,
                    FixCategories.NonBreaking,
                    MessageLevel.Warning,
                    "Remove the field 'privateInstance_NotSet_Read' since it is never set and therefore is always the default value.")
                .HasNoMoreProblems();
        }

        private string privateInstance_Set = "ABC";

        [TestMethod]
        public void PrivateInstance_Set()
        {
            new MarkFieldReadOnly()
                .RunRule(() => this.privateInstance_Set)
                .HasProblem(
                    75,
                    FixCategories.NonBreaking,
                    MessageLevel.Warning,
                    "Mark the field 'privateInstance_Set' as readonly.")
                .HasNoMoreProblems();
        }

        private static string privateStatic_NotSet_NotRead;

        [TestMethod]
        public void PrivateStatic_NotSet_NotRead()
        {
            new MarkFieldReadOnly()
                .RunRule(() => TestMarkFieldReadOnly.privateStatic_NotSet_NotRead)
                .HasProblem(
                    75,
                    FixCategories.NonBreaking,
                    MessageLevel.Warning,
                    "Remove the field 'privateStatic_NotSet_NotRead' since it is never set and therefore is always the default value.")
                .HasNoMoreProblems();
        }

        private static string privateStatic_NotSet_Read;
        public static void Read_field2()
        {
            string x = TestMarkFieldReadOnly.privateStatic_NotSet_Read;
            string y = x;
        }

        [TestMethod]
        public void PrivateStatic_NotSet_Read()
        {
            new MarkFieldReadOnly()
                .RunRule(() => TestMarkFieldReadOnly.privateStatic_NotSet_Read)
                .HasProblem(
                    75,
                    FixCategories.NonBreaking,
                    MessageLevel.Warning,
                    "Remove the field 'privateStatic_NotSet_Read' since it is never set and therefore is always the default value.")
                .HasNoMoreProblems();
        }

        private static string privateStatic_Set = null;

        [TestMethod]
        public void PrivateStatic_Set()
        {
            new MarkFieldReadOnly()
                .RunRule(() => TestMarkFieldReadOnly.privateStatic_Set)
                .HasProblem(
                    75,
                    FixCategories.NonBreaking,
                    MessageLevel.Warning,
                    "Mark the field 'privateStatic_Set' as readonly.")
                .HasNoMoreProblems();
        }
    }
}
#pragma warning restore 169, 414, 649